$(bodyDimensions = function(){
	var dim;
	if(self.innerWidth!=undefined) {
		dim = [self.innerWidth,self.innerHeight];
	}
	else{
		var D= document.documentElement;
		if(D) {dim = [D.clientWidth,D.clientHeight];}
	}
	return dim;
});
/*$(function() {
	var b = bodyDimensions();
	log.debug(b[1])
});*/


function elementDimensions(elem){
	a = $(elem);
	offset = a.offset();
	return a = [offset.left , offset.top];
};


/* Присутствие
*******************************************/
$(function() {
	var which = $(".mPresence");
	which.click(function(){
		var cid = $(which).attr('id'); 
		log.debug(cid);
		if(boxerInplace.inited == true) {
			boxerInplace.hide();
		} else {
			var text = '<div class="owBlock" style=""><ol style="list-style: none;">'
				+ '<li class="mpl1" title="mpOut"><a href="" title="неявка">неявка</a></li>'
				+ '<li class="mpl2"><a href="#">опоздание</a></li>'
				+ '<li class="mpl3" title="mpIll"><a href="" title="болезнь">болезнь</a></li>'
				+ '<li class="mpl4"><a href="">пропуск</a></li>'
				+ '</div>';
			boxerInplace.show(which , text , {delay : false ,className : "confirm2"});
			
			var linkObj = $('.owBlock li a');
			linkObj.hover(function(){
				var xClass = $(this).parent().attr('title');
				which.removeAttr('class').addClass(xClass);
				$(this).click(function(){
					boxerInplace.hide();
					return false;
				});
			},
			function(){
				which.removeAttr('class').addClass('mPresence');
			});
//			linkObj.click(function(){return false;});
		}
	});
});


/* Коментарии
 ****************************************/
$(function() {
	var which = $(".mC div span");

	which.click(function(){
		if (myComment.active != true) {
			var zdf = myComment.show($(this));
		}
		zdf.blur(function(){
//			$('.owButSubmit').click(function(){myComment.hideOk();});
			myComment.hide();
		});
	});
	var destr = $('html').find(".mC div a");
	destr.click(function(){
		boxerInplace.show( destr, 'fsdfsdf', { 
		buttons: [
			{ text : yestext || "Да",
			  callback : yescallback
			},
			{ text : notext || "Нет",
			  callback : nocallback
			}
		],
		delay : false,
		className : "confirm"
	});
		yescallback =  myComment.destroy($(this));
	});
});


(function($){
myComment = {
	options : {
		buttons : []
		,zVisible : 2000
		,zActive : false
//		,zTextDefault : '<div class="mcNone">нажмите что бы добавить коментарий</div>'
		,zTextDefault : 'нажмите что бы добавить коментарий'
	},
	
	show: function (element) {
		var zThis = element;
		this.zElement = element;
		this.zTextOld = zThis.html();
		this.zOldType = zThis.parent().attr('class');
		this.zElement.parent().removeClass(this.zOldType);

		var zAreaText = '';
		if (this.zOldType == 'mcText') {zAreaText = this.zTextOld;}
		var zHtml = '<div class="zDiv" style="z-index:1000;"><textarea style="font-size:11px; width:210px;" class="zText">'
				+ zAreaText + '</textarea>'
				+'</div>';
		
		if (this.active !== true) {
//		$('<div style="position:absolute; top:0; left:0; width:100%; height:100%; z-index:100;" id="overlay"></div>').appendTo($("body"));
			zThis.empty().html(zHtml);
			this.zElement.parent().find('a').hide();
			var zArea = zThis.find('textarea');
			zArea.focus();
		
			this.active = true;
			return zArea;
		}
	},
	hide: function() {
		this.zNewText = $('.zDiv textarea').val();
		if(this.zNewText == '') {
			//myAjax.response();
			this.zElement.parent().addClass('mcNone');
			zHtmlOut = this.options.zTextDefault;
			this.zElement.parent().find('a').hide();
		}
		else {
			zHtmlOut = ''+ this.zNewText +'';
			this.zElement.parent().addClass('mcText');
			this.zElement.parent().find('a').show();
		}
		this.zElement.empty().html(zHtmlOut);
		
		this.active = false;
	},
	destroy : function(element) {
		element.parent().removeClass().addClass('mcNone');
		zHtmlOut = this.options.zTextDefault;
		element.parent().find('span').empty().html(zHtmlOut);
		element.hide();
	}
};
})(jQuery);



(function($){ myAjax = {
	option : {
		simpleAjax : false
	},
	response : function() {
		$('.test1').fadeOut(1000, function(){alert('OK');});
	}
};
})(jQuery);

/*$(function(){
	$('.test1').addClass('ffff');
});*/

/*$(function(){
	$('.mH').click(function(){
		boxerInplace.hide();
	});
});*/

/*$(function() {
	var d = $(".mPresence")
	boxerInplace.show(d , 'dsds' , {delay : false});
});*/




/*
log.debug( 'this is a debug message' );
log.info( 'this is an info message' );
log.warn( 'this is a warning message' );
log.error( 'this is an error message' );
*/

